<?php
class basicTest extends model
{
    
    const ValidRule_id_test_isInt = 'ValidRule-id_test-isInt';
    const ValidRule_id_test_exists = 'ValidRule-id_test-exists';
    const ValidRule_id_network_teached_isInt = 'ValidRule-id_network_teached-isInt';
    const ValidRule_id_network_teached_exists = 'ValidRule-id_network_teached-exists';
    const ValidRule_id_test_data_isInt = 'ValidRule-id_test_data-isInt';
    const ValidRule_id_test_data_exists = 'ValidRule-id_test_data-exists';
    const ValidRule_output_exists = 'ValidRule-output-exists';

	
    public $id_test;
    public $id_network_teached;
    public $id_test_data;
    public $output;


	public static function loadModel($id=null, $join=null)
	{
		$obiekt = new Test($id, $join);
		if(!$obiekt ->isNull())
			return $obiekt;
		else return null;
	}
				
	public static function loadSpecialModel($where){
		$stmt = self::$db -> query("SELECT * FROM Test WHERE $where LIMIT 1;");
		$row = $stmt -> fetch(PDO::FETCH_ASSOC);
		if(!$row)
			return self::loadModel();
		$model = self::loadModel();
		$model -> SetValues($row);
		$model -> NewRecord = false;
		return $model;
	}

	public static function getAll($where=null)
	{
		return model::getAll('Test', $where);
	}

	public function __construct($id=null, $join = null)
	{
		parent::__construct($id, $join);
		$this -> labels = array(
            'id_test' => 'id_test', 
            'id_network_teached' => 'id_network_teached', 
            'id_test_data' => 'id_test_data', 
            'output' => 'output'
        );
	}

		
	public function getTableName()
	{
		return 'Test';
	}

	public function getPrimaryKey()
	{
		return 'id_test';
	}

	public function getColumns()
	{
		return array('id_test', 'id_network_teached', 'id_test_data', 'output');
	}

	protected function getBoolColumns()
	{
		return array();
	}

	public function getRules($ignore=array())
	{
		$rules = array(
            'ValidRule-id_test-isInt' => new ValidRule('id_test', isInt, array(&$this->id_test)),
            'ValidRule-id_test-exists' => new ValidRule('id_test', exists, array(&$this->id_test)),
            'ValidRule-id_network_teached-isInt' => new ValidRule('id_network_teached', isInt, array(&$this->id_network_teached)),
            'ValidRule-id_network_teached-exists' => new ValidRule('id_network_teached', exists, array(&$this->id_network_teached)),
            'ValidRule-id_test_data-isInt' => new ValidRule('id_test_data', isInt, array(&$this->id_test_data)),
            'ValidRule-id_test_data-exists' => new ValidRule('id_test_data', exists, array(&$this->id_test_data)),
            'ValidRule-output-exists' => new ValidRule('output', exists, array(&$this->output))	
        );			

		if(!empty($ignore))
		{
			if(!is_array($ignore)) $ignore = array($ignore);
			foreach($ignore as $field)
			{
				unset($rules[$field]);
			}
		}
		return $rules;

	}

    protected function getJoinTables() {
        return array('test_data', 'network_teached');
    }


}
?>